import http from '../../util/http';
import * as api from '../../util/api';

const state ={

};
const actions={
    addCars({commit},a){  //添加商品到购物车
        let clientId=sessionStorage.getItem('clientId')
        console.log(a.time)
        return http({
            url:api.addCars,          //添加商品到购物车
            method:'post',
            data:{
                addTime:a.time,    //加入时间
                clientId:"7bff3ee541e746f786623dfc7bb39cfb",  //客户id
                goodsId:a.id,  //商品编码
                goodsNumber:a.obj //商品数量
            }
        }).then(res=>{
            commit('getGoodsCar',res.data.code)
            // console.log(res.data)
            return res.data.data //将数据返回给页面，处理异步
        }).catch(err=>{
            console.log(err)
        })
    },
};
const mutations ={
       getGoodsCar(state,obj){    //加入购物车
        state.GoodsCar = obj
    },
};
export default{
    state,
    actions,
    mutations,
}